﻿using B.S.BaseData.Domain.Entities;
using B.S.BaseData.ErrorCode;
using B.S.BaseData.Write.API.Command.ApplyCommand;
using B.S.BaseData.Write.API.Command.MenuCommand;
using B.S.BaseData.Write.API.Command.RoleCommand;
using B.S.BaseData.Write.API.Command.UserCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BaseData.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private readonly IMediator mediator;

        public UserController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddUser(AddUserCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> DelUser(DelUserCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> UpdUser(UpdUserCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddRole(CreateRoleCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 更新角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> UpdateRole(UpdateRoleCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> DelRole(DelRoleCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加角色用户关系表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> CreateRoleUser(CreateRoleUserCommand request)
        {
            return await mediator.Send(request);
        }

      /// <summary>
      /// 删除角色用户关系表
      /// </summary>
      /// <param name="request"></param>
      /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> DelRoleUser(DelRoleUserCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 添加菜单表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddMenu(AddMenuCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除菜单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelMenu(DelMenuCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> UpdateMenu(UpdateMenuCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 添加角色菜单关系表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddRoleMenu(AddRoleMenuCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 提交申请
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddApp(AddAppCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除申请
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<List<Apply>>> DelApply(DelAppBYIdCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改申请
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> UpdApply(UpdApplyCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 审批功能
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> Apply(ApplyCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
